﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Storage.RemoteStorage.Sevice.Entity;
using System.Text;

namespace Storage.RemoteStorage.Sevice.Helper
{
    public static class VirtualPathHelper
    {
        public static string getRelativePath(string PhisicalPath,string RootPath)
        {
            return PhisicalPath.Except(RootPath).ToString();
        }
        public static string GetRelativePath(VirtualFolder folder)
        {
            string PathSeparator = System.IO.Path.DirectorySeparatorChar.ToString();
            StringBuilder str = new StringBuilder();
            VirtualFolder current = folder;
            while (current!=null && !current.IsRoot)
            {
                str=str.Insert(0,current.Name);
                str = str.Insert(0,PathSeparator);
                current = current.Parent;
            }
            return str.ToString();
        }
    }
}